import http from "@/http/index";
import { join } from "path";

// 根据优惠券名称和类型分页获取优惠券列表
export const ApiCouponData = (
  params: ICouponParams
): RES<ICouponData<ICouponList>> => http.get("/coupon/list", { params });

// 添加优惠卷
export const ApiAddCoupon = (params: IAddParams): RES<number> =>
  http.post("/coupon/create", params);

// 获取单个优惠券的详细信息
export const ApiCouponItemById = (id: number): RES<IAddParams> =>
  http.get(`/coupon/${id}`);

// 删除优惠券
export const ApiDeleteCoupon = (id: number): RES<number> =>
  http.post(`/coupon/delete/${id}`);

// 修改优惠券
export const ApiUpdateCoupon = (id: number, params: IAddParams): RES<number> =>
  http.post(`/coupon/update/${id}`, params);

// 根据优惠券id，使用状态，订单编号分页获取领取记录
export const ApiCouponHistory = (
  params: ICouponByIdParams
): RES<ICouponData<ICouponList>> => http.get("/couponHistory/list", { params });

//以下是品牌推荐的接口
//品牌列表
export const brandSearchApi = (
  params: IBrandListParams
): RES<IBrandListModel> =>
  http.get(
    `/home/brand/list?brandName=${params.brandName}&pageNum=${params.pageNum}&pageSize=${params.pageSize}&recommendStatus=${params.recommendStatus}`
  );
//删除品牌
export const deleteBrandApi = (ids: number[]): RES<any> =>
  http.post(`/home/brand/delete?ids=${ids.join(",")}`);

//修改推荐品牌排序
export const updateBrandSortApi = (id: number, sort: number): RES<any> =>
  http.post(`/home/brand/update/sort/${id}?sort=${sort}`);

//批量修改推荐品牌状态
export const updateRecommendStatusApi = (
  ids: number[],
  recommendStatus: number
): RES<any> =>
  http.post(
    `/home/brand/update/recommendStatus?ids=${ids.join(
      ","
    )}&recommendStatus=${recommendStatus}`
  );
//根据品牌名称分页获取品牌列表
export const brandListApi = (params: IUserListParams): RES<ILittleBrandModel> =>
  http.get(
    `/brand/list?keyword=${params.keyword}&pageNum=${params.pageNum}&pageSize=${params.pageSize}`
  );

//小窗添加首页推荐品牌
export const createBrandApi = (pmsBrand: createBrandParams[]): RES<any> =>
  http.post(`/home/brand/create`, pmsBrand);

//新品推荐api
//分页查询首页新品
export const newProductListApi = (
  params: IProductParam
): RES<INewProductModel> =>
  http.get(
    `/home/newProduct/list?productName=${params.productName}&pageNum=${params.pageNum}&pageSize=${params.pageSize}&recommendStatus=${params.recommendStatus}`
  );
//批量删除首页新品
export const deleteNewProductApi = (ids: number[]): RES<any> =>
  http.post(`/home/newProduct/delete?ids=${ids.join(",")}`);
//修改首页新品排序
export const updateNewProductSortApi = (id: number, sort: number): RES<any> =>
  http.post(`/home/newProduct/update/sort/${id}?sort=${sort}`);
//批量修改首页新品状态
export const updateNewProductRecommendStatusApi = (
  ids: number[],
  recommendStatus: number
): RES<any> =>
  http.post(
    `/home/newProduct/update/recommendStatus?ids=${ids.join(
      ","
    )}&recommendStatus=${recommendStatus}`
  );
//查询商品
export const NewProductListApi = (
  params: IUserListParams
): RES<ILittleNewProductModel> =>
  http.get(
    `/product/list?keyword=${params.keyword}&pageNum=${params.pageNum}&pageSize=${params.pageSize}`
  );
//添加首页新品
export const createNewProductApi = (
  pmsBrand: createNewProductParams[]
): RES<any> => http.post(`/home/newProduct/create`, pmsBrand);

//人气推荐api
//分页查询荐
export const RecommendProductListApi = (
  params: IProductParam
): RES<IRecommendProductListModel> =>
  http.get(
    `/home/recommendProduct/list?productName=${params.productName}&pageNum=${params.pageNum}&pageSize=${params.pageSize}&recommendStatus=${params.recommendStatus}`
  );
//批量删除推荐
export const deleteRecommendProductApi = (ids: number[]): RES<any> =>
  http.post(`/home/recommendProduct/delete?ids=${ids.join(",")}`);
//批量修改推荐状态
export const updateRecommendProductRecommendStatusApi = (
  ids: number[],
  recommendStatus: number
): RES<any> =>
  http.post(
    `/home/recommendProduct/update/recommendStatus?ids=${ids.join(
      ","
    )}&recommendStatus=${recommendStatus}`
  );
//修改推荐排序
export const updateRecommendProductSortApi = (
  id: number,
  sort: number
): RES<any> =>
  http.post(`/home/recommendProduct/update/sort/${id}?sort=${sort}`);
//添加首页推荐
export const createRecommendProductApi = (
  pmsBrand: createNewProductParams[]
): RES<any> => http.post(`/home/recommendProduct/create`, pmsBrand);

//专题推荐api
export const recommendSubjectListApi = (
  params: IRecommendSubjectParam
): RES<INewProductModel> =>
  http.get(
    `/home/recommendSubject/list?subjectName=${params.subjectName}&pageNum=${params.pageNum}&pageSize=${params.pageSize}&recommendStatus=${params.recommendStatus}`
  );
//批量删除推荐
export const delRecommendSubjectApi = (ids: number[]): RES<any> =>
  http.post(`/home/recommendSubject/delete?ids=${ids.join(",")}`);
//批量修改推荐状态
export const updateRecommendSubjectStatusApi = (
  ids: number[],
  recommendStatus: number
): RES<any> =>
  http.post(
    `/home/recommendSubject/update/recommendStatus?ids=${ids.join(
      ","
    )}&recommendStatus=${recommendStatus}`
  );
//修改推荐排序
export const updateRecommendSubjectSortApi = (
  id: number,
  sort: number
): RES<any> =>
  http.post(`/home/recommendSubject/update/sort/${id}?sort=${sort}`);
//根据专题名称分页获取专题
export const subjectListApi = (params: IUserListParams): RES<ISubjectModel> =>
  http.get(
    `/subject/list?keyword=${params.keyword}&pageNum=${params.pageNum}&pageSize=${params.pageSize}`
  );
//添加首页推荐专题
export const createRecommendSubjectApi = (
  pmsBrand: ICreateSubjectParams[]
): RES<any> => http.post(`/home/recommendSubject/create`, pmsBrand);
// 秒杀活动全部场次
export const flashListApi = (
  params: IFlashParams
): RES<ITableResult<flashList>> => http.get("/flash/list", { params });

// 秒杀活动删除
export const deleteFlashListApi = (id: number): RES<number> =>
  http.post(`/flash/delete/${id}`);

// 根据id获取活动详情
export const getFlashIdApi = (id: number): RES<any> => http.get(`/flash/${id}`);

// 秒杀活动添加活动
export const addFlashListApi = (params: IAddFlashList): RES<number> =>
  http.post("/flash/create", params);

// 秒杀活动编辑活动
export const editFlashListApi = (params: IEditFlashList): RES<number> =>
  http.post(`/flash/update/${params.id}`, params);

// 获取秒杀时间段列表
export const getFlashTimeListApi = (): RES<IFlashTimeList[]> =>
  http.get("/flashSession/list");

// 修改场次
export const changeFlashTimeListApi = (
  id: number,
  status: 0 | 1
): RES<number> =>
  http.post(`/flashSession/update/status/${id}?status=${status}`);

// 删除时间场次
export const delFlashSessionApi = (id: number): RES<number> =>
  http.post(`/flashSession/delete/${id}`);

// 添加秒杀时间段列表
export const addFlashSessionListApi = (
  params: IAddFlashSessionList
): RES<number> => http.post("/flashSession/create", params);

// 获取时间段场次详情
export const getFlashSessionDetailApi = (id: number): RES<IFlashTimeList> =>
  http.get(`/flashSession/${id}`);

// 编辑时间段 场次
export const editFlashSessionApi = (params: IFlashTimeList): RES<number> =>
  http.post(`/flashSession/update/${params.id}`, params);

// 秒杀活动设置商品
export const getFlashSessionSelectListApi = (
  flashPromotionId: number
): RES<ISelectSessionList[]> =>
  http.get("/flashSession/selectList?flashPromotionId=" + flashPromotionId);

// 获取flash里的商品列表
export const getFlashGoodsListApi = (
  params: IGetGoodsListParams
): RES<IGoodsListData> => http.get("/product/list", { params });

// 批量选择商品添加关联
export const flashProductRelationCreateApi = (
  params: IFlashProductRelationCreate[]
): RES<number> => http.post("/flashProductRelation/create", params);

// 获取管理商品促销信息
export const getFlashProductRelationApi = (
  id: number
): RES<IFlashProductRelationCreate> => http.get(`/flashProductRelation/${id}`);

// 修改秒杀相关信息
export const updateFlashProductRelationApi = (
  params: IFlashProductRelationList
): RES<number> =>
  http.post(`/flashProductRelation/update/${params.id}`, params);

// 分页查询不同场次关联及商品信息
export const getFlashProductRelationListApi = (
  params: IGetFlashProductRelationListParams
): RES<IFlashProductRelationData> =>
  http.get("/flashProductRelation/list", { params });

// 删除关联
export const deleteFlashProductRelationApi = (id: number): RES<number> =>
  http.post(`/flashProductRelation/delete/${id}`);

  // 获取广告列表数据
export const getAdsListAPI=(params:IProductParam):RES<AdsData>=>http.get(`/home/advertise/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}`)

// 删除广告列表数据
export const deleteAdsListAPI = (id: number[]): RES<IUpdateProductDate> => http.post(`/home/advertise/delete?ids=${id.join(',')}`,)

// 查询广告列表数据
  export const InquireListAPI=(params:Inquire):RES<AdsData>=>http.get(`/home/advertise/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}&name=${params.name}&endTime=${params.endTime}&type=${params.type}`)

// 修改上线下线
export const updateStatusAPI=(id:number,sort:number):RES<IUpdateProductDate>=>http.post(`/home/advertise/update/status/${id}?status=${sort}`)

// 添加广告
export const createAdvertiseAPI=(params:createAdvertise):RES<IUpdateProductDate>=>http.post(`/home/advertise/create`,params)

// 编辑广告获取数据
export const AdvertiseAPI=(id:number):RES<AdsList>=>http.get(`/home/advertise/${id}`)

// 修改广告
export const updateAdvertiseAPI=(id:number,params:createAdvertise):RES<IUpdateProductDate>=>http.post(`/home/advertise/update/${id}`,params)
